package com.haidechizi.leetcode;

/**
 * @author: wangdejun
 * @create: 2020-04-03 11:12
 **/
public class _24_反转链表 {

    public ListNode reverseList(ListNode head) {
        ListNode newHead = new ListNode(0);
        while (head != null) {
            ListNode next = newHead.next;
            newHead.next = head;
            ListNode headNext = head.next;
            head.next = next;
            head = headNext;
        }
        return newHead.next;
    }
}
